#include "DXUT.h"

#include "Heightmap.h"

void Heightmap::init(int seed, int destWidth, int destHeight, int x, int z) {
	perlin.SetSeed(seed);
	//perlin.SetFrequency(1.0f);

	heightMapBuilder.SetSourceModule (perlin);
	heightMapBuilder.SetDestNoiseMap (heightMap);
	heightMapBuilder.SetDestSize (destWidth, destHeight);
	heightMapBuilder.SetBounds ((x / 256.0), ((x+256) / 256.0), (z / 256.0), ((z+256) / 256.0));
	heightMapBuilder.Build ();
}

Heightmap::Heightmap(int destWidth, int destHeight, int x, int z) {
	init(0, destWidth, destHeight, x, z);
}

Heightmap::Heightmap(int seed, int destWidth, int destHeight, int x, int z) {
	init(seed, destWidth, destHeight, x, z);
}

Heightmap::~Heightmap() {

}

float Heightmap::getHeight(int x, int z) {
	return heightMap.GetValue(x, z);
}